<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page import="com.control.ScoreControl"%>
<%@ page import="com.model.Score"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title></title>
	</head>
	<body>
		<%
			int student_id = (Integer) session.getAttribute("id");
			int course_id = Integer.parseInt(request.getParameter("course_id"));
			int type = Integer.parseInt(request.getParameter("type"));
			ScoreControl sc = new ScoreControl();
			Score score = new Score();
			score.setCourse_id(course_id);
			score.setStudent_id(student_id);
			score.setPoint(-1);
			//System.out.println("type="+type);
			//System.out.println("course_id="+course_id);
			//System.out.println("student_id="+student_id);
			if (type == 0) {
				if(sc.insertScore(score)){
		%>
		<script>
                	alert("选课成功！");
                	window.location.href("select_index.jsp");
        </script>
		<%
				} else {
		%>
					<script>
		      		    alert("选课失败！");
		          		window.location.href("select_index.jsp");
		    		</script>
				<%} 
				}
			else {
				if(sc.deleteScore(score)){
		%>
		<script>
             		alert("退课成功！");
            		window.location.href("select_index.jsp");
        </script>
		<%
				}else{
		%>
					<script>
             		alert("退课失败！");
            		window.location.href("select_index.jsp");
        			</script>
        <%}} %>
	</body>
</html>